/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gametheory;

import java.awt.geom.Point2D;
import java.util.ArrayList;

/**
 *
 * @author 3mara
 */
public class Person extends Utility {

    Camera assignedCamera;
    ArrayList<Camera> cameraList;
    Point2D.Double point;
    double prevUtility = 0;
    double expectUtility = 0;
    int id = -1;

    public Person(Point2D.Double point, Camera cam) {
        this.point = point;
        this.assignedCamera = cam;
        cameraList = new ArrayList<Camera>();
    }

    public double getUtility() {
        double utility = 0;
        for (int crt = 0; crt < this.criteriaList.size(); crt++) {
            for (int p = 0; p < assignedCamera.assignedPersons.size(); p++) {
                utility += this.criteriaList.get(crt).getScore(this.assignedCamera, this);
            }
            for (int p = 0; p < assignedCamera.assignedPersons.size(); p++) {
                if (!assignedCamera.assignedPersons.get(p).equals(this.point)) {
                    utility -= this.criteriaList.get(crt).getScore(this.assignedCamera, this);
                }
            }
        }
        this.prevUtility = utility;
        return utility;
    }

    public double getExpectedUtility(Camera cam, double prop) {
        if (cameraList.contains(cam)) {
            double temp = prevUtility + ((1 / prop) * (prevUtility - expectUtility));
            expectUtility = temp;
            return expectUtility;
        } else {
            return prevUtility;
        }
    }
}
